#!/bin/bash

nc=`which nc`
[ ! -x "$nc" ] && exit 1

port=8080
ip=$(ifconfig eth0 | awk  '/inet addr:/{print $2}')
ip=${ip#addr:}
[ -z "$ip" ] && exit 1

status=$(printf "GET / HTTP/1.1\nHost:$ip\n\n" | nc -q 3 $ip $port | head -1) 
[ -z "$status" ] && exit 1

status=$(echo $status | awk '{printf $2}')
[ "${status:0:1}" == "2" ] && exit 0
[ "${status:0:1}" == "3" ] && exit 0
exit 1
